import AddBuyType from '../../common/add-buy-type/add-buy-type.vue'
import SwapPortfolioPosition from '../../common/swap-porfolio-position/swap-portfolio-position.vue'
import AddInverstorPortfolio from '../../common/add-inverstor-portfolio/add-inverstor-portfolio.vue'
import UpdateInverstorPortfolio from '../../common/update-inverstor-portfolio/update-inverstor-portfolio.vue'
import { getBetaList, getOriginBetaList, showMsg } from '../../../../../vuex/action.js'

export default {
  name: 'InverstorPortfolioManage',
  data() {
    return {
      showAddBuyTypeModal: false,
      showAddInverstorModal: false,
      showUpdateInverstorModal: false,
      betaList: [],
      originList: []
    }
  },
  filters: {
    getIsNewText(isNew) {
      if (isNew) {
        return '删除new标志'
      } else {
        return '添加new标志'
      }
    },
    getShelvesText(shelves) {
      if (shelves) {
        return '已上架'
      } else {
        return '已下架'
      }
    }
  },
  methods: {
    evtToogleIsNew(item) {
      item.isNew = !item.isNew
    },
    evtToogleShelves(item) {
      item.shelves = !item.shelves
    },
    evtAddInverstor() {
      this.showAddInverstorModal = true
    },
    evtUpdateInverstor() {
      this.showUpdateInverstorModal = true
    },
    evtAddBuyType() {
      this.showAddBuyTypeModal = true
    },
    getBetaList() {
      var params = {
        start: 0,
        limit: 10
      }
      return this.xGetBetaList(params).then((res) => {
        this.betaList = res.data.list
      }).catch((res) => {
        this.xShowMsg({
          type: 'danger',
          content: res.error_msg
        })
      })
    },
    getOriginBetaList() {
      var params = {
        start: 0,
        limit: 10
      }
      this.xGetOriginBetaList(params).then((res) => {
        // console.log(res)
        // this.originList = res.data.list
      })
    }
  },
  vuex: {
    actions: {
      xShowMsg: showMsg,
      xGetBetaList: getBetaList,
      xGetOriginBetaList: getOriginBetaList
    }
  },
  components: {
    'add-buy-type': AddBuyType,
    'swap-portfolio-position': SwapPortfolioPosition,
    'add-inverstor-portfolio': AddInverstorPortfolio,
    'update-inverstor-portfolio': UpdateInverstorPortfolio
  },
  ready() {
    this.getBetaList()
  // this.getOriginBetaList()
  }
}
